package com.pet.mapper;

import com.github.pagehelper.Page;
import com.pet.dto.web.PetHealthInformationDTO;
import com.pet.entity.PetHealthInformation;
import com.pet.pageDto.PetHealthPageDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PetHealthInformationMapper {

    @Select("select * from pet_manage_system.pet_health_information where create_user = #{currentId}")
    List<PetHealthInformation> selectPetHealthInformation(Long currentId);

    @Insert("insert into pet_manage_system.pet_health_information" +
            "(name, gender, month, breed, type, " +
            "kg, BCS, wash_time, internal_deworming, extracorporeal_deworming, " +
            "create_user, update_time, image) " +
            "VALUES " +
            "(#{name},#{gender},#{month},#{breed},#{type}," +
            "#{kg},#{bcs},#{washTime},#{internalDeworming},#{extracorporealDeworming}," +
            "#{createUser},#{updateTime}, #{image})")
    void insertPetHealthInformation(PetHealthInformation entity);

    /**
     * 修改(更新)宠物健康信息
     * @param dto
     */
    void updatePetHealthInformation(PetHealthInformationDTO dto);

    /**
     * 删除宠物健康信息
     * @param id
     */
    @Delete("delete from pet_manage_system.pet_health_information where id = #{id}")
    void deletePetHealthInformation(Integer id);

    Page<PetHealthInformation> pageQuery(PetHealthPageDTO dto);

    @Delete("delete from pet_manage_system.pet_health_information where create_user = #{userId}")
    void deletePetHealthInformationByUserId(Integer userId);

    @Select("select * from pet_manage_system.pet_health_information where id = #{id}")
    PetHealthInformation selectPetHealthInformationById(Integer id);
}
